From: Dan Winship Date: Thu, 30 Sep 2010 20:41:38 +0000 (-0400) Subject: MessageTray: untangle click notifications X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~9660 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=de16108dff4dce105d1194d8a5cd18e8af29f9aa;p=gnome-shell.git MessageTray: untangle click notifications Previously, when you clicked on a notification, it would call this.source.clicked(), which would emit a 'clicked' signal on the source, and then various other stuff would happen from there. This used to make a little bit of sense, when clicking on a notification was supposed to do the same thing as clicking on its source, but makes less sense now, when clicking on the source itself *doesn't* call source.clicked()... Change it so that when you click on a notification, the notification emits 'clicked' itself, and the source notices that and calls its notificationClicked() method, and the various source subclasses do what they need to do with that, and Source no longer has a clicked method/signal. https://bugzilla.gnome.org/show_bug.cgi?id=631042 --- diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js index d2eb30e3b..a028d3206 100644 --- a/js/ui/messageTray.js +++ b/js/ui/messageTray.js @@ -116,11 +116,6 @@ Notification.prototype = { this._capturedEventId = 0; this._keyPressId = 0; - source.connect('clicked', Lang.bind(this, - function() { - this.emit('dismissed'); - })); - source.connect('destroy', Lang.bind(this, this.destroy)); this.actor = new St.Table({ name: 'notification', @@ -130,7 +125,7 @@ Notification.prototype = { function (actor, event) { if (!this._actionArea || !this._actionArea.contains(event.get_source())) - this.source.clicked(); + this.emit('clicked'); })); // The first line should have the title, followed by the @@ -665,26 +660,26 @@ Source.prototype = { }, notify: function(notification) { - if (this.notification) + if (this.notification) { + this.notification.disconnect(this._notificationClickedId); this.notification.disconnect(this._notificationDestroyedId); + } this.notification = notification; + this._notificationClickedId = notification.connect('clicked', Lang.bind(this, this._notificationClicked)); this._notificationDestroyedId = notification.connect('destroy', Lang.bind(this, function () { if (this.notification == notification) { this.notification = null; this._notificationDestroyedId = 0; + this._notificationClickedId = 0; } })); this.emit('notify', notification); }, - clicked: function() { - this.emit('clicked'); - }, - destroy: function() { this.emit('destroy'); }, @@ -696,6 +691,10 @@ Source.prototype = { if (this._iconBin.child) this._iconBin.child.destroy(); this._iconBin.child = icon; + }, + + // Default implementation is to do nothing, but subclass can override + _notificationClicked: function(notification) { } }; Signals.addSignalMethods(Source.prototype); diff --git a/js/ui/notificationDaemon.js b/js/ui/notificationDaemon.js index bb37bfd6c..3e0bd6b46 100644 --- a/js/ui/notificationDaemon.js +++ b/js/ui/notificationDaemon.js @@ -173,10 +173,6 @@ NotificationDaemon.prototype = { let source = new Source(title, pid); this._sources[pid] = source; - source.connect('clicked', Lang.bind(this, - function() { - source.destroy(); - })); source.connect('destroy', Lang.bind(this, function() { delete this._sources[pid]; @@ -281,7 +277,7 @@ NotificationDaemon.prototype = { if (notification == null) { notification = new MessageTray.Notification(source, summary, body, { icon: iconActor }); ndata.notification = notification; - notification.connect('dismissed', Lang.bind(this, + notification.connect('clicked', Lang.bind(this, function(n) { this._emitNotificationClosed(id, NotificationClosedReason.DISMISSED); })); @@ -433,9 +429,9 @@ Source.prototype = { this.useNotificationIcon = false; }, - clicked: function() { + _notificationClicked: function() { this.openApp(); - MessageTray.Source.prototype.clicked.call(this); + this.destroy(); }, openApp: function() { diff --git a/js/ui/telepathyClient.js b/js/ui/telepathyClient.js index 9a4aaf9a9..d2269f6c2 100644 --- a/js/ui/telepathyClient.js +++ b/js/ui/telepathyClient.js @@ -484,7 +484,7 @@ Source.prototype = { this.ICON_SIZE); }, - clicked: function() { + _notificationClicked: function(notification) { channelDispatcher.EnsureChannelRemote(this._accountPath, { 'org.freedesktop.Telepathy.Channel.ChannelType': Telepathy.CHANNEL_TEXT_NAME, 'org.freedesktop.Telepathy.Channel.TargetHandle': this._targetHandle, @@ -492,8 +492,6 @@ Source.prototype = { global.get_current_time(), '', Lang.bind(this, this._gotChannelRequest)); - - MessageTray.Source.prototype.clicked.call(this); }, _gotChannelRequest: function (chanReqPath, ex) { diff --git a/js/ui/windowAttentionHandler.js b/js/ui/windowAttentionHandler.js index d99045423..b740d8def 100644 --- a/js/ui/windowAttentionHandler.js +++ b/js/ui/windowAttentionHandler.js @@ -66,7 +66,6 @@ WindowAttentionHandler.prototype = { source = new Source(app, window); this._sources[appId] = source; Main.messageTray.add(source); - source.connect('clicked', Lang.bind(this, function() { source.destroy(); })); source.connect('destroy', Lang.bind(this, function() { delete this._sources[appId]; })); } @@ -101,9 +100,8 @@ Source.prototype = { return this._app.create_icon_texture(this.ICON_SIZE); }, - clicked : function() { + _notificationClicked : function(notification) { Main.activateWindow(this._window); - MessageTray.Source.prototype.clicked.call(this); + this.destroy(); } - };